package app.lockenabler2;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;


public class Help extends Activity {
	private Button apps;
	private Button close;
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.help);
		
		// Прокрутка пальцем описания
		TextView mAbout = (TextView) findViewById(R.id.text);
		mAbout.setMovementMethod(ScrollingMovementMethod.getInstance());

		// Квикэкшн кнопка емейл
        final ActionItem wwwAction = new ActionItem();
        wwwAction.setTitle(getString(R.string.go_site));
        wwwAction.setIcon(getResources().getDrawable(R.drawable.www_icon));
        wwwAction.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                String url = "http://lockenabler2.googlecode.com";
                Intent i = new Intent(Intent.ACTION_VIEW);
                i.setData(Uri.parse(url));
                startActivity(i);
            
            }
        });
        
        // Квикэкшн кнопка сайт
        final ActionItem emailAction = new ActionItem();
        emailAction.setTitle(getString(R.string.send_mail));
        emailAction.setIcon(getResources().getDrawable(R.drawable.mail_icon));
        emailAction.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_SEND);
                intent.setType("plain/text");
                intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "kfv.kfv@gmail.com" });
                intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.mail_subj));
                intent.putExtra(Intent.EXTRA_TEXT, getString(R.string.need_help) + getString(R.string.mail_device) + " " + android.os.Build.MODEL + "\n" + getString(R.string.mail_os) + " " + android.os.Build.VERSION.INCREMENTAL + " (" + android.os.Build.VERSION.RELEASE + ")\n");
                startActivity(Intent.createChooser(intent, ""));
            }
        });
		
        final ImageView mIcon = (ImageView) findViewById(R.id.icon); // Иконка
		
		mIcon.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_DOWN){
                    // Рисуем тень при нажатии
                    v.setBackgroundResource(R.drawable.icon_shadow);
                } else if (event.getAction() == MotionEvent.ACTION_UP) {
                    // Сбрасываем тень при отпускании
                    v.setBackgroundResource(0);
                    
                    // Рисуем квикэкшн
                    QuickAction qa = new QuickAction(v);
                    qa.addActionItem(emailAction);
                    qa.addActionItem(wwwAction);
                    qa.show();
                }
                return true;
            }
        });
				
		ImageView mPayPal = (ImageView)findViewById(R.id.paypal);
		mPayPal.setOnClickListener(new View.OnClickListener() {
            public void onClick(View arg0) {
                String url = getString(R.string.paypal)+"cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3WFRV66W2P74E";
                Intent i = new Intent(Intent.ACTION_VIEW);
                i.setData(Uri.parse(url));
                startActivity(i);
            }
        });
        
        ImageView mWebMoney = (ImageView)findViewById(R.id.webmoney);
        mWebMoney.setOnClickListener(new View.OnClickListener() {
            public void onClick(View arg0) {
                String url = getString(R.string.webmoney_url);
                Intent i = new Intent(Intent.ACTION_VIEW);
                i.setData(Uri.parse(url));
                startActivity(i);
            }
        });
        
        ImageView mYandex = (ImageView)findViewById(R.id.yandex);
        mYandex.setOnClickListener(new View.OnClickListener() {
            public void onClick(View arg0) {
                String url = getString(R.string.yandex_url);
                Intent i = new Intent(Intent.ACTION_VIEW);
                i.setData(Uri.parse(url));
                startActivity(i);
            }
        });

		apps = (Button) findViewById(R.id.otherapps);
		close = (Button) findViewById(R.id.close);
		
		apps.setOnClickListener(new View.OnClickListener() {
	           public void onClick(View arg0) {
	               
	               
	               String url = "market://search?q=pub:kfv";
	                Intent i = new Intent(Intent.ACTION_VIEW);
	                i.setData(Uri.parse(url));
	                startActivity(i);
	               
	           }
		});
		
		close.setOnClickListener(new View.OnClickListener() {
	           public void onClick(View arg0) {
	        	   finish();
	        	   return;
	           }
		});
		
		
	}
	
    @Override
    protected void onStop() {
        super.onStop();
        finish();
        return;
    }
}
